﻿using System;
using System.Collections.Generic;
using System.Text;
using CYTools.Util;
using System.Data;
using System.Data.SqlClient;
using CYTools.Models.Model;

namespace CYTools.Models.Dao
{
    public class KehuInfoDao
    {
        public Database db = new Database();
        /// <summary>
        /// get kehu info list
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<KehuInfo> getKehuInfoList(SqlConnection conn)
        {
            List<KehuInfo> KehuInfoList = new List<KehuInfo>();
            string sql = "SELECT Kehu_id,Bianma,KeHuMingcheng,LianXiRen,DianHua,ShouJi,YouZhengBianMa,DiZhi  FROM 客户管理 where Kehu_id <>1";
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        KehuInfo ui = new KehuInfo();
                        ui.Kehu_id = row["Kehu_id"].ToString();
                        ui.Bianma = row["Bianma"].ToString();
                        ui.KeHuMingcheng = row["KeHuMingcheng"].ToString();
                        ui.LianXiRen = row["LianXiRen"].ToString();
                        ui.DianHua = row["DianHua"].ToString();
                        ui.ShouJi = row["ShouJi"].ToString();
                        ui.YouZhengBianMa = row["YouZhengBianMa"].ToString();
                        ui.DiZhi = row["DiZhi"].ToString();
                        KehuInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return KehuInfoList;
        }
    }
}
